import paddlehub as hub
import cv2

face_detector = hub.Module(name="ultra_light_fast_generic_face_detector_1mb_640", version='1.1.2')
# 多张人脸测试用例
# test_img_path = "../origin/group_photo.jpeg"

# 模糊图片测试用例
# test_img_path = "../test_img/mohu.jpg"

# 正常图片测试用例
# test_img_path = "../test_img/normal.jpg"

# 异常测试用例
# test_img_path = '../test_img/negative.png'
# 人脸数为零


def detect_face_num(img_path):
    result = face_detector.face_detection(images=[cv2.imread(img_path)])
    face_num = len(result[0]['data'])
    if face_num != 1:
        return False
    else:
        return True


